import request from '@/utils/http'

const apiList = {
    role: 'home/role',
    permission: 'home/permission',
    menu: 'home/menu',
    user: 'home/user',
    resetPwd: 'home/user/resetPwd',
    updatePassword: 'user/password',
    category: 'home/category',
    product: 'home/product',
    productSupplier: 'home/product/supplier',
    batchDeleteProduct: 'home/product/delete',
    supplier: 'home/supplier',
    case: 'home/case',
    land: 'home/land',
    plant: 'home/plant',
    yieldPlant: 'home/plant/yield',
    animal: 'home/animal',
    device: 'home/device',
}

export default {
    deviceList: data => {
        return request.get(apiList.device, { params: data })
    },
    deviceAdd: data => {
        return request.put(apiList.device, data)
    },
    deviceUpdate: data => {
        return request.post(apiList.device, data)
    },
    deviceDelete: data => {
        return request.delete(apiList.device, { params: data })
    },
    animalList: data => {
        return request.get(apiList.animal, { params: data })
    },
    animalAdd: data => {
        return request.put(apiList.animal, data)
    },
    yieldPlant: data => {
        return request.get(apiList.yieldPlant, { params: data })
    },
    plantList: data => {
        return request.get(apiList.plant, { params: data })
    },
    plantAdd: data => {
        return request.put(apiList.plant, data)
    },
    landList: data => {
        return request.get(apiList.land, { params: data })
    },
    landAdd: data => {
        return request.put(apiList.land, data)
    },
    landUpdate: data => {
        return request.post(apiList.land, data)
    },
    landDelete: data => {
        return request.delete(apiList.land, { params: data })
    },
    case: data => {
        return request.get(apiList.case, { params: data })
    },
    supplierList: data => {
        return request.get(apiList.supplier, { params: data })
    },
    supplierAdd: data => {
        return request.put(apiList.supplier, data)
    },
    supplierUpdate: data => {
        return request.post(apiList.supplier, data)
    },
    supplierDelete: data => {
        return request.delete(apiList.supplier, { params: data })
    },
    batchDeleteProduct: data => {
        return request.post(apiList.batchDeleteProduct, data)
    },
    operate: data => {
        return request.get(`home/product/${data.id}/${data.operation}`)
    },
    productDelete: data => {
        return request.delete(apiList.product, { params: data })
    },
    productUpdate: data => {
        return request.post(apiList.product, data)
    },
    productAdd: data => {
        return request.put(apiList.product, data)
    },
    productSupplier: data => {
        return request.get(apiList.productSupplier, { params: data })
    },
    productList: data => {
        return request.get(apiList.product, { params: data })
    },
    categoryList: data => {
        return request.get(apiList.category, { params: data })
    },
    categoryAdd: data => {
        return request.put(apiList.category, data)
    },
    categoryUpdate: data => {
        return request.post(apiList.category, data)
    },
    categoryrDelete: data => {
        return request.delete(apiList.category, { params: data })
    },
    updatePassword: data => {
        return request.post(apiList.updatePassword, data)
    },
    resetPwd: data => {
        return request.get(apiList.resetPwd + `/${data.id}`)
    },
    userList: data => {
        return request.get(apiList.user, { params: data })
    },
    userAdd: data => {
        return request.put(apiList.user, data)
    },
    userUpdate: data => {
        return request.post(apiList.user, data)
    },
    userDelete: data => {
        return request.delete(apiList.user, { params: data })
    },
    roleList: data => {
        return request.get(apiList.role, { params: data })
    },
    roleDelete: data => {
        return request.delete(apiList.role, { params: data })
    },
    roleAdd: data => {
        return request.put(apiList.role, data)
    },
    roleUpdate: data => {
        return request.post(apiList.role, data)
    },
    permissionList: data => {
        return request.get(apiList.permission, { params: data })
    },
    setPermission: data => {
        return request.post(apiList.permission, data)
    }, 
    menuList: data => {
        return request.get(apiList.menu, { params: data })
    },
    menuUpdate: data => {
        return request.post(apiList.menu, data)
    },
    menuAdd: data => {
        return request.put(apiList.menu, data)
    },
    menuDelete: data => {
        return request.delete(apiList.menu, { params: data })
    },
}